package Z06XianCheng.XC06JiaoHu;

public class XCJiaoHu {
    public static void main(String[] args) {
        final XCHero gareen = new XCHero();
        gareen.name = "盖伦";
        gareen.hp = 616;

        Thread t1 = new Thread(){
            public void run(){
                while (true){
                    while (gareen.hp == 1){
                        continue;
                    }
                    gareen.hurt();
                    System.out.printf("t1 为%s 减血1点,减少血后，" +
                            "%s的血量是%.0f%n",gareen.name,gareen.name,gareen.hp);
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        t1.start();

        Thread t2 = new Thread(){
            public void run(){
                while (true){
                    gareen.recover();
                    System.out.printf("t2 为%s 回复1点,回复血后，" +
                            "%s的血量是%.0f%n",gareen.name,gareen.name,gareen.hp);
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        t2.start();


    }
}
